package com.uzai.console.web.takebal;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.takebal.redpacket.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.takebal.RedPacketService;
import com.uzai.console.service.takebal.RedPacketSyncService;
import com.uzai.console.vo.takebal.redpacket.RedPacketCopyVo;
import com.uzai.console.vo.takebal.redpacket.RedPacketInfoVo;
import com.uzai.console.vo.takebal.redpacket.RedPacketTotalVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "红包列表",tags = "提现管理|红包列表")
@ApiSort(16)
@RestController
public class RedPacketContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(RedPacketContoller.class);

    @Autowired
    private RedPacketService redPacketService;
    @Autowired
    private RedPacketSyncService redPacketSyncService;


    @ApiOperation(value = "分页查询红包列表", notes = "分页查询红包列表", response = RedPacketInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/redPacket/findRedPacketList")
    public Object findRedPacketList(@RequestBody RedPacketQuery redPacketQuery){
        return redPacketService.findRedPacketList(redPacketQuery);
    }

    @ApiOperation(value = "查询红包详情", notes = "查询红包详情", response = RedPacketInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/redPacket/findRedPacketInfo")
    public Object findRedPacketInfo(@RequestBody RedPacketIdDto redPacketIdDto){
        return redPacketService.findRedPacketInfo(redPacketIdDto);
    }

    @ApiOperation(value = "查询红包总金额", notes = "查询红包总金额", response = RedPacketTotalVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/redPacket/findRedPacketTotal")
    public Object findRedPacketTotal(@RequestBody RedPacketQuery redPacketQuery){
        return redPacketService.findTotalMoney(redPacketQuery);
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "发送筛选结果中全部未领取", notes = "发送筛选结果中全部未领取")
    @ApiOperationSupport(order = 4)
    @PostMapping("/redPacket/seedCardALLUnReceived")
    public Object seedCardALLUnReceived(@RequestBody RedPacketBatchSendMsgDto redPacketBatchSendMsgDto){
        redPacketSyncService.sendCardToUnReceivedSelectedSync(redPacketBatchSendMsgDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "批量发送未领取红包(多选框)", notes = "批量发送未领取红包(多选框)")
    @ApiOperationSupport(order = 4)
    @PostMapping("/redPacket/sendCardToUnReceivedBatch")
    public Object sendCardToUnReceivedBatch(@RequestBody RedPacketSelectedSendMsgDto redPacketSelectedSendMsgDto){
        redPacketSyncService.sendCardToUnReceivedBatchSync(redPacketSelectedSendMsgDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "作废筛选结果中全部未领取", notes = "作废筛选结果中全部未领取")
    @ApiOperationSupport(order = 5)
    @PostMapping("/redPacket/invalidALLUnReceived")
    public Object invalidALLUnReceived(@RequestBody RedPacketQuery redPacketQuery){
        redPacketSyncService.invalidALLUnReceived(redPacketQuery);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "作废并偿还筛选结果中全部未领取", notes = "作废并偿还筛选结果中全部未领取")
    @ApiOperationSupport(order = 5)
    @PostMapping("/redPacket/invalidAndRebackALLUnReceived")
    public Object invalidAndRebackALLUnReceived(@RequestBody RedPacketQuery redPacketQuery){
        redPacketSyncService.invalidAndRebackALLUnReceived(redPacketQuery);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量作废未领取红包(多选框)", notes = "批量作废未领取红包(多选框)")
    @ApiOperationSupport(order = 5)
    @PostMapping("/redPacket/invalidALLUnReceivedBatch")
    public Object invalidALLUnReceivedBatch(@RequestBody RedPacketIdListDto redPacketIdListDto){
        redPacketSyncService.invalidALLUnReceivedBatchSync(redPacketIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量作废并偿还未领取红包(多选框)", notes = "批量作废并偿还未领取红包(多选框)")
    @ApiOperationSupport(order = 5)
    @PostMapping("/redPacket/invalidAndRebackALLUnReceivedBatch")
    public Object invalidAndRebackALLUnReceivedBatch(@RequestBody RedPacketIdListDto redPacketIdListDto){
        redPacketSyncService.invalidAndRebackALLUnReceivedBatchSync(redPacketIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "发送红包卡片", notes = "发送红包卡片")
    @ApiOperationSupport(order = 6)
    @PostMapping("/redPacket/sendCardToOneRedPacketUnReceived")
    public Object sendCardToOneRedPacketUnReceived(@RequestBody RedPacketSendMsgDto redPacketSendMsgDto){
        redPacketService.sendCardToOneRedPacketUnReceived(redPacketSendMsgDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "作废", notes = "作废")
    @ApiOperationSupport(order = 7)
    @PostMapping("/redPacket/invalidToOneRedPacketUnReceived")
    public Object invalidToOneRedPacketUnReceived(@RequestBody RedPacketIdDto redPacketIdDto){
        redPacketService.invalidToOneRedPacketUnReceived(redPacketIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "作废并偿还", notes = "作废并偿还")
    @ApiOperationSupport(order = 7)
    @PostMapping("/redPacket/invalidAndRebackToOneRedPacketUnReceived")
    public Object invalidAndRebackToOneRedPacketUnReceived(@RequestBody RedPacketIdDto redPacketIdDto){
        redPacketService.invalidAndRebackToOneRedPacketUnReceived(redPacketIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.COPY)
    @ApiOperation(value = "复制红包地址", notes = "复制红包地址", response = RedPacketCopyVo.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/redPacket/copyRedPacketUrl")
    public Object copyRedPacketUrl(@RequestBody RedPacketIdDto redPacketIdDto){
        return redPacketService.copyRedPacketUrl(redPacketIdDto);
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.SENDMESSAGE)
    @ApiOperation(value = "发送消息", notes = "发送消息")
    @ApiOperationSupport(order = 9)
    @PostMapping("/redPacket/sendMessage")
    public Object sendMessage(@RequestBody RedPacketSendMsgDto redPacketSendMsgDto){
        redPacketService.sendMessage(redPacketSendMsgDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.SENDMESSAGE)
    @ApiOperation(value = "批量发送消息(多选框)", notes = "发送消息(多选框)")
    @ApiOperationSupport(order = 9)
    @PostMapping("/redPacket/sendMessageBatch")
    public Object sendMessageBatch(@RequestBody RedPacketSendBatchMsgDto redPacketSendBatchMsgDto){
        redPacketSyncService.sendMessageBatchSync(redPacketSendBatchMsgDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.QUERY)
    @ApiOperation(value = "查询支付结果", notes = "查询支付结果")
    @ApiOperationSupport(order = 10)
    @PostMapping("/redPacket/queryResult")
    public Object queryResult(@RequestBody RedPacketIdDto redPacketIdDto){
        redPacketService.queryResult(redPacketIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.RedPacket, type = OperationTypeEnum.QUERY)
    @ApiOperation(value = "批量查询支付结果", notes = "批量查询支付结果")
    @ApiOperationSupport(order = 11)
    @PostMapping("/redPacket/queryResult/batch")
    public Object queryResultBatch(@RequestBody RedPacketIdListDto redPacketIdListDto){
        redPacketSyncService.queryResultBatchSync(redPacketIdListDto);
        return true;
    }

}
